﻿#include "manplugin.h"
#include "src/bend/dao/clouds/daocloudscos.h"
#include "src/bend/dao/clouds/daocloudsmock.h"
#include "src/bend/dao/configs/version.h"
#include "src/bend/dao/configs/versioncmd.h"
#include "src/bend/dao/configs/versionjson.h"
#include "src/config/globals.h"
#include "src/config/loggerproxy.h"
#include "src/middle/logger/loggerqdebug.h"
#include "src/middle/manglobal.h"
#include <QDebug>
using namespace GLOBAL;
ManPlugin::~ManPlugin()
{
    delete m_clouds;
    delete m_version;
    qDebug("delete ManPlugins ");
}
ManPlugin::ManPlugin(QObject* parent)
    : QObject(parent)
{}
DaoClouds* ManPlugin::clouds() const
{
    return m_clouds;
}

void ManPlugin::installPlugins(int argc, char* argv[])
{
    VersionCmd version(argc, argv);
    if (version.isValid()) { m_version = new VersionCmd(argc, argv); }
    else {

        m_version = new VersionJson(VERSION::JSON_PATH);
    }
    m_version->setVersion();
    //安装日志插件
    mLogIns->setLogger(new LoggerQDebug());
    //安装云存储插件
    if (m_version->major() == VERSION::MAJOR_BUSINESS) {
        // TODO
        m_clouds = new DaoCloudsCos();
    }
    else {
        m_clouds = new DaoCloudsMock(":/static/testing/custom.json");
    }
}
